<?php
/**
 *
 * @param  [type] $index_id [description]
 * @return [type]           [description]
 */
function getLastIndexByIndexType30($index_id)
{
    if (!$index_id) $index_id = 'N701|N501';
    $init_index_num_1 = substr($index_id, 1, 3) + 1;
    $init_index_num_2 = substr($index_id, 6, 3);

    if($init_index_num_2==504){
        $init_index_num_2=$init_index_num_2+2;
    }else{
        $init_index_num_2=$init_index_num_2+1;
    }
    if ($init_index_num_2 > 508) {
        $init_index_num_2 = 501;
    }
    if ($init_index_num_1 > 712) {
        $init_index_num_1 = 701;
    }
    $last_index_id = 'N' . $init_index_num_1 . '|' . 'N' . $init_index_num_2;
    echo  $last_index_id;
}
$index_id='N712|N508';
getLastIndexByIndexType30($index_id);


